package com.ruoyi.zsyh.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zsyh.domain.ZsyhElectricInstall;
import com.ruoyi.zsyh.service.IZsyhElectricInstallService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 空调安装登记Controller
 * 
 * @author yuexl
 * @date 2023-05-17
 */
@Controller
@RequestMapping("/zsyh/electricInstall")
public class ZsyhElectricInstallController extends BaseController
{
    private String prefix = "zsyh/electricInstall";

    @Autowired
    private IZsyhElectricInstallService zsyhElectricInstallService;

    @RequiresPermissions("zsyh:electricInstall:view")
    @GetMapping()
    public String electricInstall()
    {
        return prefix + "/electricInstall";
    }

    /**
     * 查询空调安装登记列表
     */
    @RequiresPermissions("zsyh:electricInstall:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZsyhElectricInstall zsyhElectricInstall)
    {
        startPage();
        List<ZsyhElectricInstall> list = zsyhElectricInstallService.selectZsyhElectricInstallList(zsyhElectricInstall);
        return getDataTable(list);
    }

    /**
     * 导出空调安装登记列表
     */
    @RequiresPermissions("zsyh:electricInstall:export")
    @Log(title = "空调安装登记", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZsyhElectricInstall zsyhElectricInstall)
    {
        List<ZsyhElectricInstall> list = zsyhElectricInstallService.selectZsyhElectricInstallList(zsyhElectricInstall);
        ExcelUtil<ZsyhElectricInstall> util = new ExcelUtil<ZsyhElectricInstall>(ZsyhElectricInstall.class);
        return util.exportExcel(list, "空调安装登记数据");
    }

    /**
     * 新增空调安装登记
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存空调安装登记
     */
    @RequiresPermissions("zsyh:electricInstall:add")
    @Log(title = "空调安装登记", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZsyhElectricInstall zsyhElectricInstall)
    {
        return toAjax(zsyhElectricInstallService.insertZsyhElectricInstall(zsyhElectricInstall));
    }

    /**
     * 修改空调安装登记
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ZsyhElectricInstall zsyhElectricInstall = zsyhElectricInstallService.selectZsyhElectricInstallById(id);
        mmap.put("zsyhElectricInstall", zsyhElectricInstall);
        return prefix + "/edit";
    }

    /**
     * 修改保存空调安装登记
     */
    @RequiresPermissions("zsyh:electricInstall:edit")
    @Log(title = "空调安装登记", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZsyhElectricInstall zsyhElectricInstall)
    {
        return toAjax(zsyhElectricInstallService.updateZsyhElectricInstall(zsyhElectricInstall));
    }

    /**
     * 删除空调安装登记
     */
    @RequiresPermissions("zsyh:electricInstall:remove")
    @Log(title = "空调安装登记", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zsyhElectricInstallService.deleteZsyhElectricInstallByIds(ids));
    }
}
